<div class="row">
    <div class="col-md-12 widget-module">
        <div class="box-widget">
            <div class="widget-head clearfix">
                <h4 class="pull-left"><?php echo $this->translate('create product'); ?></h4>
            </div>
            
            <div class="widget-container">
                <div class="widget-block">
                    <div class="widget-content">
                        <form id="usergroup" method="post" class="form-horizontal form-box">
                            <div class="form-group <?php echo $this->classError['name']; ?>">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('product name'); ?></label>
                                <div class="col-lg-4">
                                    <input class="form-control" type="text" value="<?php echo $this->data['name']; ?>" name="name" class="form-control" id="name" placeholder="<?php echo $this->translate('product name'); ?>" />
                                    <?php echo $this->messageError['name']; ?>
                                </div>
                            </div>
                            
                            <div class="form-group <?php echo $this->classError['net']; ?>">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('net'); ?></label>
                                <div class="col-lg-4">
                                    <input class="form-control" type="text" value="<?php echo $this->data['net']; ?>" name="net" class="form-control" placeholder="<?php echo $this->translate('net'); ?>" />
                                    <?php echo $this->messageError['net']; ?>
                                </div>
                            </div>
                            
                            <div class="form-group <?php echo $this->classError['brand']; ?>">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('brand'); ?></label>
                                <div class="col-lg-4">
                                    <select name="brand" class="form-control">
                                        <?php foreach($this->brands as $brand): ?>
                                            <option <?php if(isset($this->data['brand']) && $this->data['brand'] == $brand->id) echo 'selected="selected"'; ?> value="<?php echo $brand->id; ?>"><?php echo $brand->brand; ?></option>
                                        <?php endforeach; ?>
                                    </select>
                                    <?php echo $this->messageError['brand']; ?>
                                </div>
                            </div>
                            
                            <div class="form-group <?php echo $this->classError['price']; ?>">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('price'); ?></label>
                                <div class="col-lg-4">
                                    <input class="form-control" type="text" value="<?php echo $this->data['price']; ?>" id="price" class="form-control" placeholder="<?php echo $this->translate('price'); ?>" />
                                    <input type="hidden" value="<?php echo $this->data['price']; ?>" name="price" />
                                    <?php echo $this->messageError['price']; ?>
                                </div>
                            </div>
                            
                            <div class="form-group <?php echo $this->classError['customer']; ?>">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('customer'); ?></label>
                                <div class="col-lg-4">
                                    <select class="form-control" name="customer">
                                        <option <?php if($this->data['customer'] == 0) echo 'selected="selected"'; ?> value="0">Tất cả khách hàng</option>
                                        <?php foreach($this->customers as $row): ?>
                                            <option  <?php if($this->data['customer'] == $row->id) echo 'selected="selected"'; ?> value="<?php echo $row->id; ?>"><?php echo $row->name; ?></option>
                                        <?php endforeach; ?>
                                    </select>
                                    <?php echo $this->messageError['customer']; ?>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-lg-2 control-label">&nbsp;</label>
                                <div class="col-lg-4">
                                    <div class="form-actions">
                                        <button type="submit" class="btn btn-primary">
                                            <i class="icon-save"></i>
                                            <?php echo $this->translate('save'); ?>
                                        </button>
                                        <button id="cancel" type="button" class="btn">
                                            <i class="icon-cancel-circle-2"></i>
                                            <?php echo $this->translate('cancel'); ?>
                                        </button>
                                    </div>
                                </div>
                            </div> 
                            <?php if(isset($this->data['id']) && $this->data['id'] > 0): ?>
                            <input type="hidden" name="id" value="<?php echo $this->data['id']; ?>" />
                            <input type="hidden" name="save" value="1" />
                            <?php endif; ?>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<style>
select{
    text-transform: capitalize;
}
</style>
<script>
$("#cancel").click(function(){
    window.location = "<?php echo $this->url(array('module' => 'admin', 'controller' => 'product', 'action' => 'index'), null, true); ?>";
});

$(document).ready(function(){
    $("#name").focus();
    
    var optionNumeric = {'aSep': '.', 'aDec': ',', 'mDec': 0, 'vMin': 0, 'vMax': 999999999999};
    $("#price").autoNumeric('init', optionNumeric);
    $("#price").change(function(){
        var value = $(this).autoNumeric('get');
        
        $("input[name='price']").val(value);
    });
});
</script>